package com.hengpeng.itfin.persist.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.hengpeng.common.persist.AbstractDao;
import com.hengpeng.common.persist.query.DynamicQuery;
import com.hengpeng.common.persist.query.constants.QueryConstants.QueryType;
import com.hengpeng.itfin.persist.RebateDao;
import com.hengpeng.itfinbase.en.RewardRebateStatus;
import com.hengpeng.itfinbase.persist.RewardRebate;

@Repository
public class RebateDaoImpl extends AbstractDao<RewardRebate> implements RebateDao {

    @Override
    public List<RewardRebate> findRewardRebateByStatus(RewardRebateStatus status, int fetchSize) {
        DynamicQuery query = new DynamicQuery(RewardRebate.class);
        query.eq("status", status);
        query.le("paytime", new Date());
        query.setPageIndex(1);
        query.setPageIndex(fetchSize);
        query.setQueryType(QueryType.JDBC);
        return super.findAllByDynamicQuery(query);
    }

    @Override
    public int updateStatus(long id, RewardRebateStatus oldStatus, RewardRebateStatus newStatus, Date updateTime) {
        return super.exeNamedQuery("rebate.updateStatus", new Object[] { newStatus, updateTime, id, oldStatus });
    }

}
